home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
PC World Komputer 2010 April
/
PCWorld0410.iso
/
pluginy Firefox
/
2108
/
2108.xpi
/
content
/
style.xbl
< prev
next >
Wrap
Extensible Markup Language
|
2009-09-26
|
12KB
|
303 lines
<?xml version="1.0"?>
<!DOCTYPE bindings [
<!ENTITY % extensionsDTD SYSTEM "chrome://mozapps/locale/extensions/extensions.dtd">
<!ENTITY % manageDTD SYSTEM "chrome://stylish/locale/manage.dtd">
<!ENTITY % commonDTD SYSTEM "chrome://stylish/locale/common.dtd">
%extensionsDTD;
%manageDTD;
%commonDTD;
]>
<bindings xmlns="http://www.mozilla.org/xbl" xmlns:xbl="http://www.mozilla.org/xbl" xmlns:xul="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul">
<binding id="regular">
<resources>
<stylesheet src="chrome://stylish/skin/style.css"/>
</resources>
<content>
<xul:hbox flex="1" context="_child">
<xul:vbox>
<xul:image anonid="status-icon" ondblclick="document.getBindingParent(this).toggleEnabled()"/>
<xul:spacer flex="1"/>
</xul:vbox>
<xul:vbox flex="1">
<xul:label anonid="name" crop="end" xbl:inherits="value=style-name"/>
<xul:label anonid="tags" crop="end" xbl:inherits="value=tags"/>
<xul:label anonid="id" crop="end" xbl:inherits="value=style-id"/>
<xul:label anonid="type" crop="end" xbl:inherits="value=type"/>
<xul:deck anonid="actions">
<xul:hbox anonid="edit-actions" flex="1">
<xul:button anonid="edit" label="&editstyle;" oncommand="document.getBindingParent(this).edit()"/>
<xul:spacer flex="1"/>
<xul:button anonid="enable" label="&cmd.enable.label;" accesskey="&cmd.enable.accesskey;" oncommand="document.getBindingParent(this).enable()"/>
<xul:button anonid="disable" label="&cmd.disable.label;" accesskey="&cmd.disable.accesskey;" oncommand="document.getBindingParent(this).disable()"/>
<xul:button anonid="delete" label="&cmd.uninstall.label;" accesskey="&cmd.uninstall2.accesskey;" oncommand="document.getBindingParent(this).delete()"/>
</xul:hbox>
<xul:hbox anonid="update-actions" flex="1">
<xul:label anonid="update-status"/>
<xul:spacer flex="1"/>
<xul:button anonid="update" label="&update;" accesskey="&update.ak;" style="display:none" oncommand="document.getBindingParent(this).update()"/>
<xul:button anonid="update-done" label="&done;" accesskey="&done.ak;" style="display:none" oncommand="document.getBindingParent(this).updateDone()"/>
</xul:hbox>
<xul:progressmeter anonid="update-progress" mode="undetermined"/>
</xul:deck>
</xul:vbox>
<xul:menupopup>
<xul:menuitem anonid="context-edit" label="&editstyle;" oncommand="document.getBindingParent(this).edit()"/>
<xul:menuitem anonid="context-enable" label="&cmd.enable.label;" accesskey="&cmd.enable.accesskey;" oncommand="document.getBindingParent(this).enable()"/>
<xul:menuitem anonid="context-disable" label="&cmd.disable.label;" accesskey="&cmd.disable.accesskey;" oncommand="document.getBindingParent(this).disable()"/>
<xul:menuitem anonid="context-delete" label="&cmd.uninstall.label;" accesskey="&cmd.uninstall2.accesskey;" oncommand="document.getBindingParent(this).delete()"/>
<xul:menuitem anonid="homepage" label="&cmd.homepage.label;" accesskey="&cmd.homepage.accesskey;" oncommand="document.getBindingParent(this).visitHomepage()"/>
<xul:menuitem anonid="find-update" label="&cmd.checkUpdate.label;" accesskey="&cmd.checkUpdate.accesskey;" oncommand="document.getBindingParent(this).findUpdate()"/>
</xul:menupopup>
</xul:hbox>
</content>
<implementation>
<property name="styleObject"/>
<constructor>
this.reload();
var that = this;
var strings = document.getElementById("extensionsStrings");
var strings2 = document.getElementById("stylishStrings");
function $(id) {
return document.getAnonymousElementByAttribute(that, "anonid", id);
}
// add observers
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
this.updateCheckStartObserver = {
observe: function(subject, topic, data) {
if (subject.id != that.styleObject.id) {
return;
}
$("update-done").style.display = "none";
$("actions").selectedIndex = 2;
that.setAttribute("update", "true");
}
}
observerService.addObserver(this.updateCheckStartObserver, "stylish-style-update-check-start", false);
this.updateCheckDoneObserver = {
observe: function(subject, topic, data) {
if (subject.id != that.styleObject.id) {
return;
}
var updateResultMessage;
switch (data) {
case "no-update-available":
updateResultMessage = strings.getString("noUpdatesMsg");
$("update-done").style.display = "";
setTimeout(function(){that.updateDone()}, 5000);
break;
case "no-update-possible":
updateResultMessage = strings2.getString("updateNotPossible");
$("update-done").style.display = "";
setTimeout(function(){that.updateDone()}, 5000);
break;
case "update-check-error":
updateResultMessage = strings2.getString("updateCheckError");
$("update-done").style.display = "";
break;
case "update-available":
updateResultMessage = strings2.getString("updateAvailable");
$("update-done").style.display = "none";
$("update").style.display = "";
break;
}
$("update-status").value = updateResultMessage;;
$("actions").selectedIndex = 1;
that.setAttribute("update", "true");
}
}
observerService.addObserver(this.updateCheckDoneObserver, "stylish-style-update-check-done", false);
this.updateStartObserver = {
observe: function(subject, topic, data) {
if (subject.id != that.styleObject.id) {
return;
}
$("update-done").style.display = "none";
$("actions").selectedIndex = 2;
that.setAttribute("update", "true");
}
}
observerService.addObserver(this.updateStartObserver, "stylish-style-update-start", false);
this.updateDoneObserver = {
observe: function(subject, topic, data) {
if (subject.id != that.styleObject.id) {
return;
}
var updateResultMessage;
switch (data) {
case "no-update-possible":
updateResultMessage = strings.getString("noUpdatesMsg");
break;
case "update-failure":
updateResultMessage = strings2.getString("updateFailed");
break;
case "update-success":
updateResultMessage = strings2.getString("updateCompleted");
break;
}
$("update-status").value = updateResultMessage;
$("update").style.display = "none"
$("update-done").style.display = "";
$("actions").selectedIndex = 1;
that.setAttribute("update", "true");
}
}
observerService.addObserver(this.updateDoneObserver, "stylish-style-update-done", false);
</constructor>
<destructor>
this.destroy();
</destructor>
<method name="destroy">
<body>
var observerService = Components.classes["@mozilla.org/observer-service;1"].getService(Components.interfaces.nsIObserverService);
observerService.removeObserver(this.updateCheckStartObserver, "stylish-style-update-check-start");
observerService.removeObserver(this.updateCheckDoneObserver, "stylish-style-update-check-done");
observerService.removeObserver(this.updateStartObserver, "stylish-style-update-start");
observerService.removeObserver(this.updateDoneObserver, "stylish-style-update-done");
</body>
</method>
<method name="reload">
<body>
<![CDATA[
var that = this;
var s = this.styleObject;
function $(id) {
return document.getAnonymousElementByAttribute(that, "anonid", id);
}
this.setAttribute("style-name", s.name);
this.setAttribute("tags", s.getMeta("tag", {}).join(" "));
this.setAttribute("type", s.getMeta("type", {}).join(" "));
$("homepage").disabled = !s.url;
$("find-update").disabled = !s.updateUrl;
$("context-enable").hidden = s.enabled;
$("context-disable").hidden = !s.enabled;
//isDisabled so we get Firefox's styles, is-disabled so people can still style this (bug 282328)
this.setAttribute("is-disabled", !s.enabled);
this.setAttribute("isDisabled", !s.enabled);
]]>
</body>
</method>
<method name="findUpdate">
<body>
this.styleObject.checkForUpdates();
</body>
</method>
<method name="update">
<body>
this.styleObject.applyUpdate();
</body>
</method>
<method name="delete">
<body>
stylishCommon.deleteWithPrompt(this.styleObject);
</body>
</method>
<method name="enable">
<body>
this.styleObject.enabled = true;
this.styleObject.save();
</body>
</method>
<method name="disable">
<body>
this.styleObject.enabled = false;
this.styleObject.save();
</body>
</method>
<method name="toggleEnabled">
<body>
this.styleObject.enabled = !this.styleObject.enabled;
this.styleObject.save();
</body>
</method>
<method name="edit">
<body>
<![CDATA[
stylishCommon.openEditForStyle(this.styleObject);
]]>
</body>
</method>
<method name="visitHomepage">
<body>
openURL(this.styleObject.url);
</body>
</method>
<method name="updateDone">
<body>
var that = this;
function $(id) {
return document.getAnonymousElementByAttribute(that, "anonid", id);
}
$("actions").selectedIndex = 0;
this.removeAttribute("update");
</body>
</method>
</implementation>
<handlers>
<handler event="click">
var parent = this.parentNode;
if (parentNode.nodeName == "style-container")
parent = parent.parentNode;
if (parent.currentSelection == this)
return;
if (parent.currentSelection)
parent.currentSelection.removeAttribute("selected");
parent.currentSelection = this;
this.setAttribute("selected", "true");
</handler>
<handler event="dblclick">
this.edit();
</handler>
</handlers>
</binding>
<binding id="container">
<resources>
<stylesheet src="chrome://stylish/skin/style.css"/>
</resources>
<content>
<xul:vbox flex="1" context="_child">
<xul:hbox anonid="heading">
<xul:button anonid="twisty" xbl:inherits="label"/>
</xul:hbox>
<xul:vbox anonid="children">
<children/>
</xul:vbox>
<xul:menupopup>
<xul:menuitem anonid="context-enable" label="&cmd.enable.label;" accesskey="&cmd.enable.accesskey;" oncommand="document.getBindingParent(this).enable()"/>
<xul:menuitem anonid="context-disable" label="&cmd.disable.label;" accesskey="&cmd.disable.accesskey;" oncommand="document.getBindingParent(this).disable()"/>
<xul:menuitem anonid="context-delete" label="&cmd.uninstall.label;" accesskey="&cmd.uninstall2.accesskey;" oncommand="document.getBindingParent(this).delete()"/>
<xul:menuitem anonid="find-update" label="&cmd.checkUpdate.label;" accesskey="&cmd.checkUpdate.accesskey;" oncommand="document.getBindingParent(this).findUpdate()"/>
</xul:menupopup>
</xul:vbox>
</content>
<implementation>
<method name="toggle">
<body>
<![CDATA[
if (this.getAttribute("closed") == "true")
this.removeAttribute("closed");
else
this.setAttribute("closed", "true");
]]>
</body>
</method>
</implementation>
<handlers>
<handler event="click">
if (event.target != this || event.button != 0)
return;
this.toggle();
</handler>
</handlers>
</binding>
</bindings>